{ ***  cef_urlrequest_capi.h  *** }

    PCefUrlRequest = ^TCefUrlRequest;
    PCefUrlRequestClient = ^TCefUrlRequestClient;

    // Structure used to make a URL request. URL requests are not associated with a
    // browser instance so no cef_client_t callbacks will be executed. URL requests
    // can be created on any valid CEF thread in either the browser or render
    // process. Once created the functions of the URL request object must be
    // accessed on the same thread that created it.
    TCefUrlRequest = record
        // Base structure.
        base: TCefBase;

        // Returns the request object used to create this URL request. The returned
        // object is read-only and should not be modified.
        get_request: function(self: PCefUrlRequest): PCefRequest; cconv;

        // Returns the client.
        get_client: function(self: PCefUrlRequest): PCefUrlRequestClient; cconv;

        // Returns the request status.
        get_request_status: function(self: PCefUrlRequest): TCefUrlRequestStatus; cconv;

        // Returns the request error if status is UR_CANCELED or UR_FAILED, or 0
        // otherwise.
        get_request_error: function(self: PCefUrlRequest): TCefErrorCode; cconv;

        // Returns the response, or NULL if no response information is available.
        // Response information will only be available after the upload has completed.
        // The returned object is read-only and should not be modified.
        get_response: function(self: PCefUrlRequest): PCefResponse; cconv;

        // Cancel the request.
        cancel: procedure(self: PCefUrlRequest); cconv;
    end;


    // Structure that should be implemented by the cef_urlrequest_t client. The
    // functions of this structure will be called on the same thread that created
    // the request.
    TCefUrlRequestClient = record
        // Base structure.
        base: TCefBase;

        // Notifies the client that the request has completed. Use the
        // cef_urlrequest_t::GetRequestStatus function to determine if the request was
        // successful or not.
        on_request_complete: procedure(
            self: PCefUrlRequestClient;
            request: PCefUrlRequest); cconv;

        // Notifies the client of upload progress. |current| denotes the number of
        // bytes sent so far and |total| is the total size of uploading data (or -1 if
        // chunked upload is enabled). This function will only be called if the
        // UR_FLAG_REPORT_UPLOAD_PROGRESS flag is set on the request.
        on_upload_progress: procedure(
            self: PCefUrlRequestClient;
            request: PCefUrlRequest;
            current, total: UInt64); cconv;

        // Notifies the client of download progress. |current| denotes the number of
        // bytes received up to the call and |total| is the expected total size of the
        // response (or -1 if not determined).
        on_download_progress: procedure(
            self: PCefUrlRequestClient;
            request: PCefUrlRequest;
            current, total: UInt64); cconv;

        // Called when some part of the response is read. |data| contains the current
        // bytes received since the last call. This function will not be called if the
        // UR_FLAG_NO_DOWNLOAD_DATA flag is set on the request.
        on_download_data: procedure(
            self: PCefUrlRequestClient;
            request: PCefUrlRequest;
            const data: Pointer;
            data_length: csize_t); cconv;

        // Called on the IO thread when the browser needs credentials from the user.
        // |isProxy| indicates whether the host is a proxy server. |host| contains the
        // hostname and |port| contains the port number. Return true (1) to continue
        // the request and call cef_auth_callback_t::cont() when the authentication
        // information is available. Return false (0) to cancel the request. This
        // function will only be called for requests initiated from the browser
        // process.
        ///
        //int (CEF_CALLBACK *get_auth_credentials)(
        //    struct _cef_urlrequest_client_t* self, int isProxy,
        //    const cef_string_t* host, int port, const cef_string_t* realm,
        //    const cef_string_t* scheme, struct _cef_auth_callback_t* callback);
        get_auth_credentials: function(
            self: PCefUrlRequestClient;
            isProxy: Integer;
            const host: PCefString;
            port: Integer;
            const realm: PCefString;
            const scheme: PCefString;
            callback: PCefAuthCallback): Integer; cconv;
    end;

    // Create a new URL request. Only GET, POST, HEAD, DELETE and PUT request
    // functions are supported. The |request| object will be marked as read-only
    // after calling this function.
    tfn_cef_urlrequest_create = function(
        request: PCefRequest;
        client: PCefUrlRequestClient): PCefUrlRequest; cdecl;

